package com.tomehay.termprojectmanage_server.mapper;
import java.util.List;

import com.tomehay.termprojectmanage_server.pojo.VO.AllocationVO;
import org.apache.ibatis.annotations.Param;

import com.tomehay.termprojectmanage_server.pojo.Model.Allocation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tomehay
 * @since 2023-06-20
 */
public interface AllocationMapper extends BaseMapper<Allocation> {
    List<Allocation> selectAllByTermProjectId(@Param("termProjectId") Integer termProjectId);
    @Select("SELECT allocation.id,allocation.group_id,termproject.title,allocation.term_project_id " +
            "FROM allocation,termproject WHERE " +
            "termproject.course_id = #{course_id} AND allocation.term_project_id = termproject.id ")
    List<AllocationVO> getAllocationVO(int course_id);

    List<Allocation> selectAllByGroupId(@Param("groupId") Integer groupId);

    List<Allocation> selectAllByGroupIdAndTermProjectId(@Param("groupId") Integer groupId, @Param("termProjectId") Integer termProjectId);

    @Select("SELECT allocation.id,allocation.group_id,termproject.title,allocation.term_project_id " +
            "FROM allocation,termproject WHERE " +
            "allocation.group_id = #{group_id} AND allocation.term_project_id = termproject.id ")
    List<AllocationVO> getAllocationVOByGroupId(int group_id);
}
